package com.Android.Intr;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class EventEntry implements Comparable<EventEntry>{
	private String dateStart;
	private String dateEnd;
	private String model;
	private String longitude;
	private String location;
	private String society;
	private String latitude;
	private String description;
	private String title;
	private int pk;
	private int year;
	private int month;
	private int day;
	private int hour;
	private int minute;
	private int second;
	
	public Date convertStringToDate(String string){
		String str_date=string;
		DateFormat formatter ; 
		formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
		try {
			return (Date)formatter.parse(str_date);
		} catch (ParseException e) {
		} 
		return null;
	}
	
	public String getStartDate(){
		return dateStart.substring(0, 10);
	}
	
	public String getStartTime(){
		return dateStart.substring(11, 16);
	}
	
	@Override
	public int compareTo(EventEntry another) {
		// TODO Auto-generated method stub
		return convertStringToDate(dateStart).compareTo(convertStringToDate(another.dateStart));
		//return dateStart.compareTo(another.dateStart);
	}

	public String getDateStart() {
		return dateStart;
	}



	public void setDateStart(String dateStart) {
		this.dateStart = dateStart;
	}



	public String getDateEnd() {
		return dateEnd;
	}



	public void setDateEnd(String dateEnd) {
		this.dateEnd = dateEnd;
	}



	public String getModel() {
		return model;
	}



	public void setModel(String model) {
		this.model = model;
	}



	public String getLongitude() {
		return longitude;
	}



	public void setLongitude(String longitude) {
		this.longitude = longitude;
	}



	public String getLocation() {
		return location;
	}



	public void setLocation(String location) {
		this.location = location;
	}



	public String getSociety() {
		return society;
	}



	public void setSociety(String society) {
		this.society = society;
	}



	public String getLatitude() {
		return latitude;
	}



	public void setLatitude(String latitude) {
		this.latitude = latitude;
	}



	public String getDescription() {
		return description;
	}



	public void setDescription(String description) {
		this.description = description;
	}



	public String getTitle() {
		return title;
	}



	public void setTitle(String title) {
		this.title = title;
	}



	public int getPk() {
		return pk;
	}



	public void setPk(int pk) {
		this.pk = pk;
	}

	public String getDateAndTitle(){
		return title+"  "+dateStart;
	}
	
	static String convertDateToString(Date date){
		int month = date.getMonth();
		String monthString = null;
		int day = date.getDate();
		switch(month){
			case 0: monthString = "Jan";break;
			case 1: monthString = "Feb";break;
			case 2: monthString = "Mar";break;
			case 3: monthString = "Apr";break;
			case 4: monthString = "May";break;
			case 5: monthString = "Jun";break;
			case 6: monthString = "Jul";break;
			case 7: monthString = "Aug";break;
			case 8: monthString = "Sep";break;
			case 9: monthString = "Oct";break;
			case 10: monthString = "Nov";break;
			case 11: monthString = "Dec";break;
			default: monthString = null;
		}
		return day+" "+monthString+" "+date.getHours()+":"+date.getMinutes();
	}
}
